package priv.abadstring.study.haoke.webapi.manage;

import com.alibaba.dubbo.config.annotation.Reference;
import org.springframework.stereotype.Service;
import priv.abadstring.study.haoke.dubbo.api.HouseResourcesServer;
import priv.abadstring.study.haoke.dubbo.entity.HouseResources;
import priv.abadstring.study.haoke.dubbo.dto.PageInfo;
import priv.abadstring.study.haoke.webapi.vo.Pagination;
import priv.abadstring.study.haoke.webapi.vo.TableResult;

/**
 * HouseResourcesManage
 *
 * @author aBadString
 * @date 2021-06-15 15:44:25
 */
@Service
public class HouseResourcesManage {
    @Reference(version = "1.0.0")
    private HouseResourcesServer houseResourcesServer;

    public boolean save(HouseResources houseResources){
        int result = this.houseResourcesServer.save(houseResources);
        return result == 1;
    }

    public TableResult<HouseResources> list(HouseResources houseResources, Integer currentPage, Integer pageSize) {
        PageInfo<HouseResources> pageInfo =
                this.houseResourcesServer.list(currentPage, pageSize, houseResources);
        return new TableResult<>(
                pageInfo.getRecords(),
                new Pagination(pageInfo.getPageNum(), pageInfo.getPageSize(), pageInfo.getTotal())
        );
    }

    public HouseResources getById(Long id) {
        return this.houseResourcesServer.getById(id);
    }

    public boolean update(HouseResources houseResources) {
        return this.houseResourcesServer.update(houseResources);
    }
}
